/*
 * Copyright © 2011 Nokia Corporation. All rights reserved.
 * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation. 
 * Oracle and Java are trademarks or registered trademarks of Oracle and/or its
 * affiliates. Other product and company names mentioned herein may be trademarks
 * or trade names of their respective owners. 
 * See LICENSE.TXT for license information.
 */

package com.nokia.example.compass.helpers;

import java.io.IOException;
import java.io.InputStream;
import javax.microedition.lcdui.Image;
import javax.microedition.m2g.SVGImage;
import javax.microedition.m2g.ScalableImage;

public class ImageLoader {

    private static ImageLoader self;
    private ImageLoader() {

    }
    public static ImageLoader getInstance() {
        if(self == null) {
            self = new ImageLoader();
        }
        return self;
    }

    public Image loadImage(String imagepath) throws IOException{
        InputStream in = this.getClass().getResourceAsStream(imagepath);
        Image image = Image.createImage(in);
        return image;
    }
    public SVGImage loadSVGImage(String imagepath) throws IOException {
        InputStream in = this.getClass().getResourceAsStream(imagepath);
        SVGImage svg_image = (SVGImage) ScalableImage.createImage(in, null);
        return svg_image;
    }

}
